import * as echarts from "echarts"
import AjaxEx from "./common/AjaxEx";
import {Helpers} from "./common/Helpers";

let data = AjaxEx.getJsonData("/form/chart")
Helpers.assert(data != null)
console.log("load:" + JSON.stringify(data))

let e = echarts.init(<HTMLDivElement>document.getElementById("app"))
var option: any = {
    "calculable": true,
    "title": {"text": "某地区蒸发量和降水量", "subtext": "纯属虚构"},
    "toolbox": {
        "feature": {
            "mark": {
                "show": true,
                "title": {"markUndo": "删除辅助线", "markClear": "清空辅助线", "mark": "辅助线开关"},
                "lineStyle": {"color": "#1e90ff", "type": "dashed", "width": 2}
            },
            "dataView": {"show": true, "title": "数据视图", "readOnly": false, "lang": ["数据视图", "关闭", "刷新"]},
            "magicType": {
                "show": true,
                "title": {"bar": "柱形图切换", "stack": "堆积", "tiled": "平铺", "line": "折线图切换"},
                "type": ["line", "bar"]
            },
            "restore": {"show": true, "title": "还原"},
            "saveAsImage": {"show": true, "title": "保存为图片", "type": "png", "lang": ["点击保存"]}
        }, "show": true
    },
    "tooltip": {"trigger": "axis"},
    "legend": {"data": ["蒸发量", "降水量"]},
    "xAxis": [{
        "type": "category",
        "data": ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"]
    }],
    "yAxis": [{"type": "value"}],
    "series": [{
        "name": "蒸发量",
        "type": "bar",
        "markPoint": {"data": [{"name": "最大值", "type": "max"}, {"name": "最小值", "type": "min"}]},
        "markLine": {"data": [{"name": "平均值", "type": "average"}]},
        "data": [2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3]
    }, {
        "name": "降水量",
        "type": "bar",
        "markPoint": {
            "data": [{
                "name": "年最高",
                "value": 182.2,
                "xAxis": 7,
                "yAxis": 183,
                "symbolSize": 18
            }, {"name": "年最低", "value": 2.3, "xAxis": 11, "yAxis": 3}]
        },
        "markLine": {"data": [{"name": "平均值", "type": "average"}]},
        "data": [2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3]
    }]
};
e.setOption(option);

let e1 = echarts.init(<HTMLDivElement>document.getElementById("app1"))
e1.setOption(data);
